package com.example.demo.security.sysMessage.service;


import com.example.demo.security.sysMessage.dao.MessageDao;
import com.example.demo.security.sysMessage.entity.MessagesBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageService {

    @Autowired
    private MessageDao messageDao;


    public List<MessagesBean> queryFriendMessage(Integer userId, Integer id){
        return messageDao.queryFriendMessage(userId,id);
    }

    public List<MessagesBean> queryGroupMessage(Integer id){
        return messageDao.queryGroupMessage(id);
    }
    public Integer insertMessage(MessagesBean messagesBean,Integer state){
        if (state==1){
            messagesBean.setGroupId(0);
        }else {
            messagesBean.setGroupId(messagesBean.getReceiveId());
            messagesBean.setReceiveId(0);
        }
        return messageDao.insertMessage(messagesBean);
    }
}
